//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "init_client.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

0 spawn {
	waituntil{GVAR(INIT)};
	
	// This fix is not needed anymore, it has been fixed by the f***** BIS
	// 0 spawn {
		// _timeend = time + 10;
		// waitUntil {!isNil "BIS_blendColorAlpha" || {time > _timeend}};
		// sleep 0.01;
		// player removeAllEventHandlers "HandleDamage";
		// player addEventHandler ["HandleDamage",
		// {
			// BIS_hitArray = _this; BIS_wasHit = true;
			// _return = _this select 2;
			// _results = ["PLAYER_HANDLEDAMAGE",_this] call tyr_fnc_execHandler;
			// { if (!isnil "_x" && {typename _x == typename 0} && {_x != _return}) exitWith { _return = _x };
			// } foreach _results;
			// TRACE_1("HandleDamageFixPlayerRespawnFunc",_return);
			// _return;
		// }];
	// };
	// player addEventHandler ["Respawn", {["PLAYER_RESPAWN",_this] call tyr_fnc_execHandler; 0 spawn HandleDamageFixPlayerRespawnFunc;}];
	
	if (TMF_LOADED) then {
		_ammoBoxes = [TMF_SERVER_INSTANCE_ID, QGVAR(AMMOBOXES),[]] call FFUNC(getMissionJIPVar);
		if (count _ammoBoxes > 0 && !(isNil "ioc_fnc_exec")) then {
			{ ["MSO","FillAmmoBox",_x] call ioc_fnc_exec;		
			} foreach _ammoBoxes;
		};
	};
	TRACE("Delay Executed");
};